package com.ruoyi.web.controller.basic;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BasicMessage;
import com.ruoyi.system.service.IBasicMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消息信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/basicMessage")
public class BasicMessageController extends BaseController
{
    @Autowired
    private IBasicMessageService basicMessageService;

    /**
     * 查询消息信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicMessage basicMessage)
    {
        startPage();
        List<BasicMessage> list = basicMessageService.selectBasicMessageList(basicMessage);
        return getDataTable(list);
    }

    /**
     * 导出消息信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessage:export')")
    @Log(title = "消息信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicMessage basicMessage)
    {
        List<BasicMessage> list = basicMessageService.selectBasicMessageList(basicMessage);
        ExcelUtil<BasicMessage> util = new ExcelUtil<BasicMessage>(BasicMessage.class);
        util.exportExcel(response, list, "消息信息数据");
    }

    /**
     * 获取消息信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessage:query')")
    @GetMapping(value = "/{messageId}")
    public AjaxResult getInfo(@PathVariable("messageId") Long messageId)
    {
        return success(basicMessageService.selectBasicMessageByMessageId(messageId));
    }

    /**
     * 新增消息信息
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessage:add')")
    @Log(title = "消息信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicMessage basicMessage)
    {
        return toAjax(basicMessageService.insertBasicMessage(basicMessage));
    }

    /**
     * 修改消息信息
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessage:edit')")
    @Log(title = "消息信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicMessage basicMessage)
    {
        return toAjax(basicMessageService.updateBasicMessage(basicMessage));
    }

    /**
     * 删除消息信息
     */
    @PreAuthorize("@ss.hasPermi('system:basicMessage:remove')")
    @Log(title = "消息信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{messageIds}")
    public AjaxResult remove(@PathVariable Long[] messageIds)
    {
        return toAjax(basicMessageService.deleteBasicMessageByMessageIds(messageIds));
    }
}
